package com.example.dc.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result {
    private Integer code;//响应码，200 代表成功; 404 代表客户端错误；500代表系统错误
    private String msg;  //响应信息 描述字符串
    private Object data; //返回的数据

    //成功响应
    public static Result success() {
        return new Result(200, "success", null);
    }

    public static Result success(Object data) {
        return new Result(200, "success", data);
    }

    //用户失败响应
    public static Result error() {
        return new Result(404, "error", null);
    }

    public static Result error(String msg) {
        return new Result(404, msg, null);
    }

    //系统失败响应
    public static Result systemError() {
        return new Result(500, "system error", null);
    }

    /**
     * 随机数
     * @param len
     * @return
     */
}
